package com.antd.admin.server.strategy.passwd;

import com.antd.admin.api.dto.ResetPasswdDto;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * TODO
 *
 * @author 子丶沫
 * @version 1.0
 * @date 2020/12/5 16:06
 */
@Slf4j
@Component
public class ResetPasswdContext {

    @Autowired
    private final Map<String, ResetPasswdHandler> strategyMap= Maps.newConcurrentMap();

    public ResetPasswdContext(Map<String, ResetPasswdHandler> strategyMap){
        strategyMap.forEach(this.strategyMap::put);
    }
    public boolean handleResetPasswd(ResetPasswdDto passwdDto){
        return strategyMap.get("resetPasswd"+passwdDto.getResetType()).resetPassword(passwdDto);
    }
}
